class Quciksort1{
	public static int Partition(int[] a,int low,int high){
		int i,j,temp,key;
		key = a[low];
		i=low + 1;
		j = high;
		while(true){
			while(i<j && key>=a[i])i++;
			while(key<=a[j])j--;
			if(i<j){
				temp=a[i];a[i]=a[j];a[j]=temp;
			}
			else{
				temp=a[low];a[low]=a[j];a[j]=temp;
				return j;
			}
		}
	}	
	
	public static void Sort(int[] a,int low,int high){
		int j;
		if(low<high)
		{
			j=Partition(a,low,high);
			Sort(a,low,j-1);
			Sort(a,j+1,high);
		}
	}

	public static void Println(int[] a){
		for(int i=0;i<a.length;i++)
			System.out.printf("%d ",a[i]);
	}

	public static void main(String[] args){
		int[] a = {42,37,11,98,36,72,65,10,88,78};
		System.out.println(" Before Sorting ");
		Println(a);
		Sort(a,0,a.length-1);
		System.out.println("\n After Sorting ");
		Println(a);	
	}
}